package Day07;

import java.util.Scanner;

public class Test12 {
    public static void main(String[] args) {
        int number = (int)(Math.random()*100);
        Scanner in =new Scanner(System.in);
        System.out.println("请输入一个整数(0-99)");
        while (!in.hasNextInt()) {
            System.out.println("你输入的不是(0-99)的正整数");
            System.out.println("请重新输入：");
            in.next();
        }
        int Num = 0;//猜测次数
        while (true){
            int num = in.nextInt();
            Num++;
            if (num > number) {
                System.out.println("您猜的数大了");
                System.out.println("请继续输入！");
            } else if (num < number) {
                System.out.println("您猜的数小了");
                System.out.println("请继续输入！");
            } else if (num == number) {
                if (Num == 1)
                    System.out.println("你太有才了!  \n答案是：" + number);
                else if ((Num >= 2) && (Num <= 6))
                    System.out.println("这么快就猜出来了，很聪明么！  \n答案是：" + number);
                else if ((Num >= 7) && (Num <20))
                    System.out.println("猜了半天才猜出来，小同志，尚需努力啊！ \n答案是：" + number);
                break;
            }
            if (Num >= 20) {
                System.out.println("20次都猜不出来...,不让你猜了\n答案是："+ number);
                break;
            }
        }

    }
}
